buildscript {
    repositories {
        maven { url = 'https://maven.minecraftforge.net' }
        mavenCentral()
        maven { url = 'https://repo.spongepowered.org/maven' }
    }
    dependencies {
        classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
        classpath 'com.google.code.gson:gson:2.8.9'
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
        classpath 'org.parchmentmc:librarian:1.+'

    }
}

plugins {
    id 'net.minecraftforge.gradle' version '5.1.+'
    id 'org.parchmentmc.librarian.forgegradle' version '1.+'
}

apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'

version = '0.20a_01-alt'
group = 'mod.nero.tpsound'
archivesBaseName = 'tpsound'


java.toolchain.languageVersion = JavaLanguageVersion.of(17)

println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
minecraft {
    mappings channel: 'parchment', version: '2023.09.03-1.20.1'

    runs {
        client {
            workingDirectory project.file('run')

            property 'forge.logging.markers', 'REGISTRIES'

            property 'forge.logging.console.level', 'debug'

            property 'forge.enabledGameTestNamespaces', 'tpsound'

            arg "-mixin.config=tpsound.mixins.json"

            mods {
                tpsound {
                    source sourceSets.main
                }
            }
        }

        server {
            workingDirectory project.file('run')

            property 'forge.logging.markers', 'REGISTRIES'

            property 'forge.logging.console.level', 'debug'

            property 'forge.enabledGameTestNamespaces', 'tpsound'

            mods {
                tpsound {
                    source sourceSets.main
                }
            }
        }

        gameTestServer {
            workingDirectory project.file('run')

            property 'forge.logging.markers', 'REGISTRIES'

            property 'forge.logging.console.level', 'debug'

            property 'forge.enabledGameTestNamespaces', 'tpsound'

            mods {
                tpsound {
                    source sourceSets.main
                }
            }
        }

        data {
            workingDirectory project.file('run')

            property 'forge.logging.markers', 'REGISTRIES'

            property 'forge.logging.console.level', 'debug'

            args '--mod', 'tpsound', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')

            mods {
                tpsound {
                    source sourceSets.main
                }
            }
        }
    }
}

sourceSets.main.resources { srcDir 'src/generated/resources' }

repositories {

}

dependencies {
    annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
    testAnnotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
    minecraft 'net.minecraftforge:forge:1.20.1-47.1.0'

}

mixin {
    add sourceSets.main, "tpsound.mixins-refmap.json"
}

jar {
    manifest {
        attributes([
                "Specification-Title"     : "tpsound",
                "Specification-Vendor"    : "nero",
                "Specification-Version"   : "1", // We are version 1 of ourselves
                "Implementation-Title"    : project.name,
                "Implementation-Version"  : project.jar.archiveVersion,
                "Implementation-Vendor"   : "nero",
                "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
                "TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
                "TweakOrder": 0,
                "MixinConfigs": "tpsound.mixins.json"
        ])
    }
    rename 'mixin.refmap.json', 'tpsound.mixins.json'
}

jar.finalizedBy('reobfJar')


publishing {
    publications {
        mavenJava(MavenPublication) {
            artifact jar
        }
    }
    repositories {
        maven {
            url "file://${project.projectDir}/mcmodsrepo"
        }
    }
}

tasks.withType(JavaCompile).configureEach {
    options.encoding = 'UTF-8'
}
